package com.eshin.container;

import javax.annotation.Resource;

import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.eshin.connectionfactory.MyConnectionFactory;
@Configuration
@ConditionalOnClass(EnableRabbit.class)
public class RabbitContainerFactory {
	 
	@Autowired
	SimpleRabbitListenerContainerFactoryConfigurer configurer;
	@Resource(name="connectionFactory")
	private MyConnectionFactory connectionFactory;
	@Bean(name = "rabbitListenerContainerFactory")
	public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
		SimpleRabbitListenerContainerFactory factory = new MyRabbitListenerContainerFactory(connectionFactory);
		configurer.configure(factory, connectionFactory);
		return factory;
	}
}
